<?php
@session_start();
require_once 'config/configuration.php';
require_once "includes/classes/Database.php";
require_once 'includes/functions.php';
require_once 'model/trade.php';
require_once (DOC_ROOT.'/model/sitesettings.php');
require_once 'model/background_images.php';
require_once 'model/users.php';
require_once 'model/cms.php';
require_once 'model/analytics.php';
require_once 'model/membershipplan.php';
require_once 'model/message.php';
require_once 'emailforafterthirtydays.php';
require_once 'emailforaftertendaysforfeedback.php';

## Create Objects
/*******************************/
$settingObj = new Model_Sitesettings();	
$tradeObj = new Model_TRADE();
$userObj = new Model_Users();
$cmsObj = new Model_CMS();		
$analyticObj = new Model_Analytics();
$planObj = new Model_PLAN();
$msgObj = new Model_Message();
/*******************************/





$seoArray = $cmsObj->getDetailsSeoById(1);
$smarty->assign("seoArray",$seoArray);

## Get default seo
$default_seo = $analyticObj->getAllAnalytics();
$smarty->assign('default_seo', $default_seo);

$tradecategoryArray = $tradeObj->getAllTradesCategoryWithActiveStatus();
for($i=0;$i<count($tradecategoryArray);$i++)
{
	$str = str_replace(" ","-",$tradecategoryArray[$i]['trade_category']);
	$str1 = str_replace("&","and",$str);
	$final_str = strtolower($str1);
	$tradecategoryArray[$i]['url'] = $final_str;	
}
//echo"<pre>";print_R($tradecategoryArray);die();

$smarty->assign("tradecategoryArray",$tradecategoryArray);
if(count($tradecategoryArray)>4)
{
	$countdividebyfour = count($tradecategoryArray)/4;
}
else
	$countdividebyfour = 1;	
$smarty->assign("countdividebyfour",round($countdividebyfour));	
$Facebook = $settingObj->getSettingValueById(2);
$smarty->assign("Facebook",$Facebook);

$Twitter = $settingObj->getSettingValueById(3);
$smarty->assign("Twitter",$Twitter);

$Googleplus = $settingObj->getSettingValueById(4);
$smarty->assign("Googleplus",$Googleplus);

$youtube = $settingObj->getSettingValueById(5);
$smarty->assign("youtube",$youtube);

$imageObj  = new Model_Background_Images();
$imageDetails = $imageObj->getCurrentActiveImage();
$smarty->assign('imageDetails', $imageDetails);

if($_SESSION['getbids_id']!='')
{
	$getuserdet = $userObj->getUserDetailsByUserId($_SESSION['getbids_id']);
	$getuserplandet = $userObj->paymentHistoryAccordingToUserIdForMembershipPlan($_SESSION['getbids_id']);
	if($getuserplandet[0]['plan_id']!='')
	{
		$getplanname = $planObj->getPlanDetailsById($getuserplandet[0]['plan_id']);
		$getuserdet['planname'] = $getplanname['name'];
		$getuserdet['plannid'] = $getuserplandet[0]['plan_id'];
		$getuserdet['planamount'] = $getuserplandet[0]['amount'];
	}
	$getinboxcount =$msgObj->getCountMessageByToId($_SESSION['getbids_id']);	
	$getuserdet['inboxcount'] =$getinboxcount;
	$getsentcount =$msgObj->getCountSentMessageByToId($_SESSION['getbids_id']);	
	$getuserdet['sentcount'] =$getsentcount;
//	echo"<pre>";	print_R($getuserdet);die();	
	$smarty->assign('getuserdet', $getuserdet);
	
	$comapnyname = str_replace(" ","_",$getuserdet['companyname']);
	$smarty->assign('comapnyname', $comapnyname);
	
}
?>
